<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption />

    <ex_super_table_page v-bind="option" ref="SuperTablePage" 
      @selection-change="e => selection = e">

    </ex_super_table_page>

    


  </div>
</template>
<script>

import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import emitOnFunction from '@/mixin/emit-on-function';
let emitKey = 'wms>import_manage'
export default {
  title: 'label_import_mange',
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],
  components: {},
  data() {
    return {
      option: {
        search: {
          model: [
            { key: 'status', label: 'label_status', type: 'select', enum: 'ExcelRecordStatusEnum' },
            { key: 'startTime', label: 'label_start_time', type: 'date-picker', attrs: { type: "datetime", 'default-time': '00:00:00' } },
            { key: 'endTime', label: 'label_end_time', type: 'date-picker', attrs: { type: "datetime", 'default-time': '23:59:59' } },
          ],
        },

        table: {
          url: "/wms-api/base/WmsExcelRpc/selectListPage.json",
          urlParams: { type: 'IMPORT' },
          'cell-class-name': this.cellClassMethod,
          model: this.init_table_model(),
        },

      },


    };
  },
  methods: {
    cellClassMethod({ row, column, rowIndex, columnIndex }) {
      if (column.property == 'status') {
        if (row.status == 'SUCCESS') {
          return 'color_success'
        } else if (row.status == 'FAIL') {
          return 'color_danger'
        } else if (row.status == 'PARTIAL_SUCCESS') {
          return 'color_warning'
        } else if (row.status == 'IN_EXECUTION') {
          return 'color_primary'
        }
      }
      return ""
    },
    option_table_model() {
      return [
        { type: 'selection', clickToggle: true, keyGroup: 'label_table_operate' },
        {
          type: 'expandDesc', 'width': 80,
          expandDesc: {
            ...this.$defaultDescAttrs,
            model: [],
          },
        },
        { key: 'serviceType', label: 'label_service_type', 'min-width': 120, 'show-overflow-tooltip': true, },

        {
          key: 'businessType', label: 'label_business_type', 'min-width': 180, 'show-overflow-tooltip': true,
        },
        // { key: 'type', label: '类型', 'width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$enumShow(v, "ExcelRecordTypeEnum"), },

        { key: 'importSuccessCount', label: 'label_import_success_count', 'width': 110, 'show-overflow-tooltip': true, },
        { key: 'importErrorCount', label: 'label_import_fail_count', 'width': 110, 'show-overflow-tooltip': true, },
        { key: 'status', label: 'label_status', 'width': 130, 'show-overflow-tooltip': true, formatter: (r, c, v, i) => this.$enumShow(v, "ExcelRecordStatusEnum"), },


        {
          key: 'gmtCreate', label: 'label_start_time', 'width': 130, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$dateFormat(v),
        },
        {
          key: 'gmtModify', label: 'label_end_time', 'width': 130, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$dateFormat(v),
        },
        {
          type: 'operate', width: 160, operate: [
            {
              label: 'label_error_info_download', class: 'button_text_danger', if: (row) => row.importErrorPath, click: (row) => {
                this.download(row.importErrorPath)
              }
            },
          ],
        }
      ]
    },



    download(url) {
      if (this.$clickFast()) return
      this.$downloadFile({
        loading: true,
        oss: true,window:true,
        url,
      })

    },


  }
};

</script>
<style></style>
